// dnSpy decompiler from Assembly-CSharp.dll class: DraggableCamera
using System;
using UnityEngine;

[RequireComponent(typeof(TouchScreen))]
public abstract class DraggableCamera : CheckedMonoBehaviour
{
	public void OnEnable()
	{
		this.touchScreen.OnDragEvent += this.OnDrag;
		this.touchScreen.OnTouchDownEvent += this.OnTouchDown;
		this.touchScreen.OnTouchUpEvent += this.OnTouchUp;
		this.touchScreen.OnCanceledTapEvent += this.OnCanceledTap;
		this.touchScreen.OnTapEvent += this.OnTap;
	}

	public void OnDisable()
	{
		this.touchScreen.OnDragEvent -= this.OnDrag;
		this.touchScreen.OnTouchDownEvent -= this.OnTouchDown;
		this.touchScreen.OnTouchUpEvent -= this.OnTouchUp;
		this.touchScreen.OnCanceledTapEvent -= this.OnCanceledTap;
		this.touchScreen.OnTapEvent -= this.OnTap;
	}

	public bool IsDragEnabled
	{
		get
		{
			return this.isDragEnabled;
		}
		set
		{
			this.isDragEnabled = value;
		}
	}

	protected virtual void OnDrag(Vector3 vDistance, Vector3 newPos)
	{
		if (!this.isDragEnabled)
		{
			return;
		}
		Vector3 cameraMoveFromDrag = this.GetCameraMoveFromDrag(vDistance);
		base.transform.Translate(cameraMoveFromDrag, Space.World);
		this.ApplyCameraLimits();
	}

	protected void ApplyCameraLimits()
	{
		Vector3 position = base.transform.position;
		Vector3 position2 = new Vector3(Mathf.Max(this.xMin, Mathf.Min(this.xMax, position.x)), Mathf.Max(this.yMin, Mathf.Min(this.yMax, position.y)), Mathf.Max(this.zMin, Mathf.Min(this.zMin, position.z)));
		base.transform.position = position2;
	}

	protected abstract Vector3 GetCameraMoveFromDrag(Vector3 drag);

	protected virtual void OnTouchDown(Vector3 touchPos)
	{
	}

	protected virtual void OnTouchUp(Vector3 pos)
	{
	}

	protected virtual void OnCanceledTap()
	{
	}

	protected virtual void OnTap(Vector3 pos)
	{
	}

	public float cameraDragSpeed = 0.005f;

	protected bool isDragEnabled = true;

	protected float xMin;

	protected float xMax;

	protected float yMin;

	protected float yMax;

	protected float zMin;

	protected float zMax;

	[NonSerialized]
	private TouchScreen touchScreen;
}
